package com.kkb.controller;

import com.kkb.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.SortedSet;

@Controller
@RequestMapping("team")
//@RequestMapping("team") : 该注解指代请求以及处理该请求映射关系，可以放在类或者方法的上面
//放在类的上面，表示请求路径的一部分，该请求路径必须跟方法上@RequestMapping中的路径结合使用
//放在方法上，该请求跟对应方法正常匹配
public class TeamController {
    @Autowired
    private TeamService teamService;

    @RequestMapping("hello.do")
    public ModelAndView hello(){
        System.out.println("hello");
        teamService.findTeams();
        ModelAndView modelAndView = new ModelAndView();
//request作用域中保存一个值：   teamName                         Tom
        modelAndView.addObject("teamName","Tom");
        modelAndView.setViewName("index");
//                           /jsp/index.jsp
        return modelAndView;
    }
    @RequestMapping("add.do")
    public ModelAndView addTeam(){
        System.out.println("改变自己");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("team/add");
        return modelAndView;
    }
    @RequestMapping("delete.do")
    public ModelAndView deleteTeam(){
        System.out.println("清空自己");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("team/delete");
        return modelAndView;
    }

}
